package com.mr.example1.index;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

/*
 * 1.输入数据：
 * 		atguigu-a.txt,1
 * 		atguigu-a.txt,1
 * 		atguigu-a.txt,1
 *
 * 2.输出数据：
 * 		atguigu-a.txt,3
 */

public class Example1Reducer1 extends Reducer<Text, LongWritable, Text, LongWritable>{

	@Override
	protected void reduce(Text key, Iterable<LongWritable> values,
						  Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {

		int sum = 0;

		for (LongWritable value : values) {

			sum += value.get();

		}

		context.write(key, new LongWritable(sum));

	}
}
